package com.msh.frame.common.util;

import java.math.BigDecimal;

public class MoneyUtil {
  private static final String DEFAULT_FORMAT = "%s.%02d";
  private static final BigDecimal BIG_DECIMAL_100 = new BigDecimal(100);
  public static String fenToYuan(int fen){
    int y = 0;
    int f = 0;
    if(0 != fen){
      y = fen/100;
      f = Math.abs(fen%100);
    }
    return String.format(DEFAULT_FORMAT, y, f);
  }

  public static int yuanToFen(String yuan){
    return new BigDecimal(yuan).multiply(BIG_DECIMAL_100).intValue();
  }
}
